#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<assert.h>

void* my_memcpy(void* dest, const void* src, size_t count)
{
	void* ret = dest;
	assert(dest && src);
	while (count--)
	{
		*(char*)dest = *(char*)src;
		++(char*)dest;
		++(char*)src;
	}
	return ret;
}

void* my_memmove(void* dest, const void* src, size_t count)
{
	void* ret = dest;
	assert(dest && src);
	if (src > dest)
	{
		while (count--)
		{
			*(char*)dest = *(char*)src;
			++(char*)dest;
			++(char*)src;
		}
	}
	else
	{
		while (count--)
		{
			*((char*)dest + count) = *((char*)src + count);
		}
	}
	return ret;
}

int main()
{
	int arr[5] = { 1,2,3,4,5 };
	int arr1[20] = { 0 };
	my_memcpy(arr1, arr, 5 * sizeof(int));
	my_memmove(arr1, arr1 + 1, 2 * sizeof(int));
	my_memmove(arr1 + 1, arr1, 2 * sizeof(int));
	return 0;
}